package com.imut.hcdp.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.imut.hcdp.common.Rst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.imut.hcdp.domain.Consumer;
import com.imut.hcdp.service.IConsumerService;


@RestController
@RequestMapping("/system/consumer")
public class ConsumerController
{
    @Autowired
    private IConsumerService consumerService;



    @GetMapping("/list")
    public Rst list(Consumer consumer, HttpServletRequest request)
    {
        Rst success = Rst.success();
        success.put("data",consumerService.selectConsumerList(consumer));
        return success;
    }



    @GetMapping(value = "/{id}")
    public Rst getInfo(@PathVariable("id") Long id)
    {
        Consumer consumer = consumerService.selectConsumerById(id);
        return Rst.success(consumer);
    }


    @PostMapping
    public Rst add(@RequestBody Consumer consumer)
    {
        return Rst.success(consumerService.insertConsumer(consumer));
    }


    @PutMapping
    public Rst edit(@RequestBody Consumer consumer)
    {
        return Rst.success(consumerService.updateConsumer(consumer));
    }




	@DeleteMapping("/{ids}")
    public Rst remove(@PathVariable Long[] ids)
    {
        return Rst.success(consumerService.deleteConsumerByIds(ids));
    }
}
